home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 December / Australian PC User - December 2003 (CD2).iso / software / apps / files / dwmx2k4.exe / Disk1 / data1.cab / Configuration_En / Objects / Server / MasterDetail.js < prev    next >
Encoding:
JavaScript  |  2003-09-05  |  5.4 KB  |  216 lines

  1. // Copyright 2001, 2002, 2003 Macromedia, Inc. All rights reserved.
  2.  
  3. // *************** GLOBALS VARS *****************
  4.  
  5. var helpDoc = MM.HELP_objMasterDetail;
  6.  
  7. var COMMAND_FILE = "";
  8. var COMMAND_WINDOW = "";
  9. var USING_OLD_IMPLEMENTATION = "";
  10.  
  11. var SUPPRESS_DIALOG = false;
  12.  
  13. // ******************* API **********************
  14.  
  15. //--------------------------------------------------------------------
  16.  
  17.  
  18.  
  19. // FUNCTION:
  20. //   insertObject
  21. //
  22. // DESCRIPTION:
  23. //   Collects values from the form elements in the dialog box and
  24. //   adds the Master Detail Set
  25. //
  26. // ARGUMENTS:
  27. //   none
  28. //
  29. // RETURNS:
  30. //   string - empty upon success, or an error message
  31. //
  32. // NOTES:
  33. //   The reason that the insertion is not done from the command file
  34. //   is that there are focus issues if a dialog directly tries to insert
  35. //   content on a second page (the detail page, in this case).
  36. //
  37. //   Instead, the object calls the command file, and gets the user interface
  38. //   parameters. With the command file closed, we can call out to a function
  39. //   inside of the command file to do the actual insertion.
  40. //--------------------------------------------------------------------
  41. function insertObject()
  42. {
  43.   if (!SUPPRESS_DIALOG)
  44.   {
  45.     defineGlobals(); // define COMMAND_FILE and COMMAND_WINDOW
  46.  
  47.     var params = dwscripts.callCommand(COMMAND_FILE);
  48.   
  49.     if (params) // if the user clicked "OK" on the dialog
  50.     {
  51.       if (USING_OLD_IMPLEMENTATION)
  52.       {
  53.         COMMAND_WINDOW.createDetailPage(params)
  54.       }
  55.       else
  56.       {
  57.         COMMAND_WINDOW.createMasterDetailSet(params);
  58.       }
  59.     }
  60.   }
  61.   else
  62.   {
  63.     // NOTE: we do not seem to reload the object if only the 
  64.     //  setupStepsCompleted function is run, so we need to 
  65.     //  reset this global boolean.
  66.     
  67.     SUPPRESS_DIALOG = false;
  68.   }
  69.  
  70.   return "";
  71. }
  72.  
  73.  
  74. //--------------------------------------------------------------------
  75. // FUNCTION:
  76. //   getSetupSteps
  77. //
  78. // DESCRIPTION:
  79. //   Returns an array of steps to be displayed in an instructions
  80. //   dialog.  The first element of the array is the text that appears
  81. //   above the list.  The remaining elements are the steps, which will
  82. //   be rendered in a numbered list.
  83. //
  84. //   The steps are each HTML, which may contain JavaScript event
  85. //   handlers.  The event handlers can either be a JavaScript script
  86. //   or an "event:KeyWord" syntax.  If the latter is used, then the
  87. //   handler for KeyWord is implemented internally in the Dreamweaver
  88. //   executable.
  89. //
  90. // ARGUMENTS:
  91. //   none
  92. //
  93. // RETURNS:
  94. //   the array described above
  95. //--------------------------------------------------------------------
  96. function getSetupSteps()
  97. {
  98.   return getSetupStepsForServerObject();
  99. }
  100.  
  101.  
  102.  
  103. //--------------------------------------------------------------------
  104. // FUNCTION:
  105. //   setupStepsCompleted
  106. //
  107. // DESCRIPTION:
  108. //   Returns the number of steps (in the list of steps returned from
  109. //   getSetupSteps) that have already been completed.  This number is
  110. //   used to determine how many steps will have a check mark next to
  111. //   them.
  112. //
  113. // ARGUMENTS:
  114. //   none
  115. //
  116. // RETURNS:
  117. //   An integer - the number of check marks to be displayed, or -1
  118. //   if all steps have been completed.
  119. //
  120. // NOTE:
  121. //   Some error dialogs should appear before or instead of the steps dialog,
  122. //   which is why the check is done in this function and not somewhere else.
  123. //--------------------------------------------------------------------
  124. function setupStepsCompleted()
  125. {
  126.   var filePath = dw.getDocumentPath("document");
  127.   var serverModel = dwscripts.getServerModel();
  128.   var errMsg = "";
  129.   var retVal = 0;
  130.   // check that cursor is not inside of cfoutput tags
  131.   if (  serverModel == "ColdFusion" &&
  132.          dwscripts.canStripCfOutputTags()  )
  133.   {
  134.     errMsg = MM.MSG_NeedValidSelectionForMasterDetail;
  135.   }
  136.  
  137.    // save document if not saved
  138.   if (!filePath) 
  139.   {
  140.     if (confirm(MM.MSG_NeedSavedDocumentForMasterDetail) && 
  141.         dw.canSaveDocument(dreamweaver.getDocumentDOM())) 
  142.     {
  143.       dw.saveDocument(dreamweaver.getDocumentDOM());
  144.       filePath = dw.getDocumentPath("document");
  145.     }
  146.   }
  147.   
  148.   if (!filePath || errMsg)
  149.   {
  150.     if (errMsg) alert (errMsg)
  151.     SUPPRESS_DIALOG = true;
  152.     retVal = -1;
  153.   }
  154.   else
  155.   {
  156.     retVal = setupStepsCompletedForServerObject();
  157.   }
  158.  
  159.   return retVal;
  160. }
  161.  
  162.  
  163.  
  164. function displayHelp()
  165. {
  166.   dwscripts.displayDWHelp();
  167. }
  168.  
  169.  
  170. // ***************** LOCAL FUNCTIONS  ******************
  171.  
  172. function defineGlobals()
  173. {
  174.   var serverModel = dwscripts.getServerModel();
  175.   var configPath = dw.getConfigurationPath();
  176.   var commandFile = "";
  177.   var commandPath = "";
  178.  
  179.   switch (serverModel)
  180.   {
  181.     case "UD4-ASP_VBS":
  182.     case "UD4-ASP_JS":
  183.     case "UD4-JSP":
  184.     case "ASP_JS":
  185.     case "ASP_VBS":
  186.     case "JSP":
  187.       USING_OLD_IMPLEMENTATION = true;
  188.       commandFile = "ServerObject-MD4.htm";
  189.       break;
  190.  
  191.     case "ColdFusion":
  192.     case "ASP.NET_Csharp":
  193.     case "ASP.NET_VB":
  194.       USING_OLD_IMPLEMENTATION = false;
  195.       commandFile = "ServerObject-MasterDetail.htm";
  196.       break;
  197.  
  198.    case "PHP_MySQL":
  199.          USING_OLD_IMPLEMENTATION = false;
  200.       commandFile = "ServerObject-MastDetailPHP.htm";
  201.       break;
  202.  
  203.     default:
  204.       break;
  205.   }
  206.  
  207.   commandPath = configPath + "/Commands/" + commandFile;
  208.   COMMAND_WINDOW = dw.getDocumentDOM(commandPath).parentWindow;
  209.   COMMAND_FILE = commandFile;
  210.  
  211. }
  212.  
  213.  
  214.  
  215.  
  216.